<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>  
<jsp:include page="menu.jsp"></jsp:include>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>文件列表</title>
		<link rel="stylesheet" type="text/css" href="css/my.css" />
		<script type="text/javascript">
			function ConfirmDelete() {
				return confirm("您确定要删除此文件吗？");
			}
		</script>
		<style type="text/css">
		body {
  		 background-image: url("img/background.png");
   		 background-size: cover;
   		 font-family: "Noto Sans SC", sans-serif;
   		 text-align: center;
		}
		.d1 {
			margin: 10px auto;
   			max-width: 1300px;
   			height: 660px;
   			padding-top: 30px;
   			background-color: #FFF8DC;
    		border-radius: 8px;
   			box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
		}
		.longname{
			max-width: 100px;
  			white-space: nowrap;
  			overflow: hidden;
  			text-overflow: ellipsis;
		}
		.show tr:nth-child(even) {
   	 		background-color: #D3D3D3;  /* 你可以更改为你想要的颜色 */
		}
		.show a:hover {
 		  	color: #FF0040;
		}
		</style>
	</head>
	<body>
	<c:if test="${empty list }">
		<div style="height: 100px"></div>
		<h1 class="title">你还没有分享任何文件哦，快去上传文件吧！</h1>
	</c:if>
	<c:if test="${not empty list }">	
		<div style="height: 10px"></div>	
		<h1 class="title">文件列表</h1>
		<div class="d1">	
			<div style="height: 30px"></div>
			<table class="show">
				<tr>
					<th>序号</th>
					<th>分享用户</th>
					<th>文件名称<a href="listsort?key=filename&my=1">↑↓</a></th>
					<th>文件类型<a href="listsort?key=classification&my=1">↑↓</a></th> 
					<th style="width: 150px;">文件下载</th>
					<th style="width: 150px;">公开时间<a href="listsort?key=releasedate&my=1">↑↓</a></th>
					<th>推荐指数<a href="listsort?key=rating&my=1">↑↓</a></th>
					<th style="width: 200px;">文件描述<a href="listsort?key=description&my=1">↑↓</a></th>
					<th style="width: 200px;">操作</th>
				</tr>
				<c:forEach items="${list}" var="file" varStatus="sta">
					<tr>
						<td>${sta.count}</td>
						<td>${file.username}</td>
						<td class="longname">${file.filename}</td>
						<td>${file.classification}</td>
						<td> 
							<form action="download" method="post">
								<input type="hidden" name="filename" value="${file.filename}">
								<input type="hidden" name="filepath" value="${file.filepath}">
								<input type="submit" value="下载" class="sub2">
							</form>	
						</td>					
						<td>
							<fmt:formatDate value="${file.releasedate}" pattern="yyyy-MM-dd" />
						</td>
						<td>
							<fmt:formatNumber value="${file.rating}" pattern=".00"></fmt:formatNumber>
						</td>
						<td class="longname">${file.description}</td>
						<td>
							<button class="sub4"><a href="updateupload.jsp?id=${sta.count - 1}">编辑</a></button>
							<button class="sub4"><a href="deletefile?filename=${file.filename}&username=${file.username}" onclick="return ConfirmDelete()">删除</a></button>
						</td>						
					</tr>
				</c:forEach>
				<tr>
					<td colspan="9">${bar}</td>
				</tr>
				<tr>
					<td colspan="9">
						<form action="showmylist" class="f3">
							<div>每页显示<input type="text" name="num" value="${empty num?10:num}" width="20px">条
							<input type="hidden" name="state" value="1">
							<input type="submit" value="确定" width="20px" class="sub3"></div>
						</form>
					</td>
				</tr>
			</table>
		</div>
	</c:if>
	</body>
</html>
